package com.javatraining.corejava.homework.bicycle;

/**
 * @author kmatharasi
 * 
 * Class to define atleast 5 states , 5 methods for creating a  Bicycle object .
 *
 */
public class Bicycle {
	
	// below are the different states that are useful to define a Bicycle .
		

	private String make;
	
	public String getMake() {
		return make;
		
	}



	public void setMake(String make) {
		this.make = make;
	}



	public String getModel() {
		return model;
	}



	public void setModel(String model) {
		this.model = model;
	}



	public String getSerialNumber() {
		return serialNumber;
	}



	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}



	public int getYear() {
		return year;
	}



	public void setYear(int year) {
		this.year = year;
	}



	public int getNumberOfGears() {
		return numberOfGears;
	}



	public void setNumberOfGears(int numberOfGears) {
		this.numberOfGears = numberOfGears;
	}



	public int getGear() {
		return gear;
	}



	public void setGear(int gear) {
		this.gear = gear;
	}



	public int getCurrentSpeed() {
		return currentSpeed;
	}



	public void setCurrentSpeed(int currentSpeed) {
		this.currentSpeed = currentSpeed;
	}



	public boolean getMotion() {
		return motion;
	}



	public void setMotion(boolean motion) {
		this.motion = motion;
	}


	private String model;
	
	private String serialNumber;
	
	private int year;
	
	private int numberOfGears=4;
	
	private int gear=0;
	
	private int currentSpeed;
	
	private boolean motion=false;
	
	
	
  // below are the 5 different behaviors that a Bicycle exhibits .
	
	
	
	 public void start()
	 
	 {
		 if(motion=true)
		 {
			 System.out.println("Bicycle is started");
			 System.out.println("----------------");
		 }		 		 
		 
	 }
	 
	 
	 
	 public void accelerate(int gear, int currentSpeed)
		
	 {
		 this.gear = gear;
		 gear++;
		 currentSpeed++;
		 
		 System.out.println("Current Gear " + gear);
		 System.out.println("-----------------------");
		
		 System.out.println("Current Speed " + currentSpeed);
		 System.out.println("-------------------------------");
		 
		 if(currentSpeed > 0 || gear > 1 &&  motion==true )
		 {
			 System.out.println("Bicycle is accelerated");
			 System.out.println("-------------------");
		 }
		 	 
	 }
	 
	  
		
	 public void decelerate(int gear,int currentSpeed)
		
	 {
		 this.gear = gear;
		 gear--;
		 currentSpeed--;
		 
		 System.out.println("Current Gear " + gear);
		 System.out.println("----------------------");
		 
		 System.out.println("Current Speed " + currentSpeed);
		 System.out.println("------------------------------");
		 
		 if(gear < 2 || motion==false || currentSpeed<=10)
		 {
			 System.out.println("Bicycle is decelerated");
			 System.out.println("-------------------");
		 }
		 
	 }
	
	 
	
	
	 public void changeGear( int gear)
		
	 {
		 this.gear = gear;
		 
		 switch (gear)
		 {
		 case 1: System.out.println("Bicycle is in gear 1");
		 System.out.println("-------------------------");
		 break;
		 
		 case 2: System.out.println("Bicycle is in gear 2");
		 System.out.println("--------------------------");
		 break;
		 
		 case 3: System.out.println("Bicycle is in gear 3");
		 System.out.println("-------------------------");
		 break;
		 
		 case 4: System.out.println("Bicycle is in gear 4");
		 System.out.println("-------------------------");
		 break;
		 	 
		 default:
		 {
			 System.out.println("Invalid Gear Option");
			 System.out.println("------------------");
		 }
		 
		 }
		 		 
	 }
	 
	 
	 public void upgradeBicycle(int year,int numberOfGears)
	 {
		 
		 this.year = year;
		 this.numberOfGears=numberOfGears;
		 
		 if(year<2010 || numberOfGears<=0 )
		 {
			 System.out.println("Bicycle Tires needs to be replaced and gears need to be added");
			 System.out.println("-------------------------");
		 }
		 
		 else if (year>2010 && year<=2012)
		 
		 {
			 System.out.println("Bicycle needs to serviced");
			 System.out.println("-------------------------");
		 }
		 else{
			 System.out.println("Bicycle need not be serviced");
			 System.out.println("-------------------------");
		 }
		 
	 }
	
	
	 public void stop(boolean motion,int gear)
		
	 {
		 
		 this.motion = motion;
		 this.gear = gear;
		 
		 if(motion=false || gear==0)
		 {
			 System.out.println("Bicycle is  stopped");
			 System.out.println("--------------");
		 }
		 
		 
	 }

	
}

